package com.liudadan;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAspect {

    @Before("execution(* com.liudadan.controller.*.*(..))")
    public void before(JoinPoint joinPoint) {
        Object target = joinPoint.getTarget();
        String name = target.getClass().getSimpleName();
        String methodName = joinPoint.getSignature().getName();
        System.out.println("前置通知：方法开始执行, 类名: "+ name + ", 方法名: " + methodName);
    }
    
    @After("execution(* com.liudadan.controller.*.*(..))")
    public void after(JoinPoint joinPoint) {
        Object target = joinPoint.getTarget();
        String name = target.getClass().getSimpleName();
        String methodName = joinPoint.getSignature().getName();
        System.out.println("后置通知：方法结束执行, 类名: "+ name + ", 方法名: " + methodName);
    }
}